<template>
	<view class="page page-my-sale">
		
		<view class="block-item p-10px mb10px" v-if="list.length" v-for="i in list" :key="i.id" >
			<!-- <view flex items-center pt-5px pb5px>
				<view class="icon icon-type"></view>
				<view text-sm ml-10px mt--2px>类型： {{i.type.title}}</view>
			</view> -->
			<view flex items-center pt-5px pb5px>
				<view class="icon icon-num"></view>
				<view text-sm ml-10px mt--2px>数量： {{i.num}}</view>
			</view>
			<view flex items-center pt-5px pb5px>
				<view class="icon icon-name"></view>
				<view text-sm ml-10px mt--2px>企业名称： {{i.firm_name}}</view>
			</view>
			<view flex items-center pt-5px pb5px>
				<view class="icon icon-avatar"></view>
				<view text-sm ml-10px mt--2px>联系人： {{i.contact_name}}</view>
			</view>
			<view flex items-center pt-5px pb5px>
				<view class="icon icon-tel"></view>
				<view text-sm ml-10px mt--2px>联系电话： {{i.contact_phone}}</view>
			</view>

			<view class="image-wrap" v-if="i.goods_images.length">
				<image 
					v-for="(item,k) in i.goods_images" :key="k"
					class="image"
					:src="item"
					mode="aspectFill"
				/>
				<view class="image" v-if="i.goods_images.length%3 == 2"></view>
			</view>
		</view>

		<view v-else-if="!loading" flex items-center justify-center flex-col pt-100px color-gray>
			<view class="icon icon-nodata text-8xl"></view>
			<view pt-10px>暂无数据</view>
		</view>

	</view>

</template>

<script setup>
	import api from '@/api'
	import { ref } from 'vue'
	import { onLoad } from "@dcloudio/uni-app"

	const page_no = ref(1) 
	const page_size = ref(100) 
	const loading = ref(false)
	const loadedAll = ref(false)
	const list = ref([])

	getList()
	async function getList() {
		if(loadedAll.value) return
		loading.value = true
		const data = await api.mySale({
				page_size: page_size.value,
				page_no: page_no.value,
			})
		if(data.list.length < page_size.value) {
			loadedAll.value = true
		}
		page_no.value += 1
		list.value = [ ...list.value, ...data.list]
		loading.value = false
	}

	const goDetail = id => {
		uni.navigateTo({
			url: `/pages/demand/detail?id=${id}&type=${current.value? 'supply':'require'}`
		})
	}

</script>

<style lang="scss">
.page-my-sale {
	background-color: $uni-bg-color-hover;

	.block-item {
		background-color: white;
		.icon {
			color: gray;
		}

		.image-wrap {
			display: flex;
			padding: 10upx 0;
			justify-content: space-between;
			.image {
				width: 32%;
				height: auto;
				aspect-ratio: 3/4;
				border-radius: 4px;
			}
		}
	}

}

</style>

